/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __MC2_AICPU_UTILS_H__
#define __MC2_AICPU_UTILS_H__

#include <string>
#include "common/aicpu_hccl_def.h"
#include "hdc_pub.h"
#include "dlhns_function.h"

class MC2AicpuUtils {
public:
    static int32_t GetCpuId();
    static int32_t GetCurClusterId();
    static void PrintHcclCombinOpParam(const HccCommResParamTask &commParam);
    static void PrintHcclCommParamDesc(const HcclCommParamDesc &desc);
    static void PrintKFCTask(const KFCTask &task);
    static void PrintTilingData(const HcclKFCTilingData &tilingData);
    static void PrintTilingDataError(const HcclKFCTilingData &tilingData);
    static void PrintTilingData(const Mc2InitTilingInner &tilingData);
    static void PrintMC2AicpuContext(const AicpuComContext &ctx);
    static void PrintMC2AicpuContextError(const AicpuComContext &ctx);
    static void PrintMC2HcclOpResParam(const HcclOpResParam *resParam);
    static void PrintBuffer(const void * const buffer, uint32_t totalSize, const std::string &desc);
    static void PrintBuffer(AicpuComContext *ctx, const AivAicpuOpParam &msgAddr);
    static void OutputWorkProfLog(u32 workRcdCnt, u32 i, AicpuComProfCommLoop *commRcd, AicpuComProf *acprof,
        AicpuComContext *ctx);
    static void OutputProfLog();
    static HcclResult WaitTaskFinish(AicpuComContext *ctx, bool quitByDefault = true);
    static HcclResult TraceProfSubmit();
    static int GetSendCnt(AicpuComContext *ctx);
    static int GetRecvCnt(AicpuComContext *ctx);
    static void PrintAicDebugInfo(AicpuComContext *ctx);
    static bool IsDebugModeEquals(const AicpuComContext &ctx, const uint8_t Mode);
    static bool NeedRecordTimeTaken(const AicpuComContext &ctx);
    static std::string HcclMsgToStr(const HcclMsg &msg);
    static std::string HcclMsgExtToStr(const HcclMsgExt &msg);
    static void PrintAllHcclMsgAreaError();
    static void PrintSimpleHcclMsgArea();
    static uint32_t GenXor(HcclMsg *msg);
    static HcclResult Getkey(const AicpuComContext &ctx, u32 remoteRankId, const void *userAddr,
        u64 length, u32 &outKey, int32_t keyType);
    static HcclResult PostSend(const AicpuComContext &ctx, u32 remoteRankId, struct std::vector<hccl::Transport::Buffer> &remoteBuf,
        struct std::vector<hccl::Transport::Buffer> &localBuf, bool isWrite);
    static bool CheckIfServerCanStart(const AicpuComContext &ctx);
};
#endif // __MC2_AICPU_UTILS_HPP__